﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.Master" AutoEventWireup="true"
    CodeBehind="AdminProducts.aspx.cs" Inherits="FlowersStore.AdminProducts" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <h2 class="AdminPart">
            Товары</h2>
    </div>
    <div>
        <asp:Label class="AdminSubPart" Text="Категория:" runat="server" />
        <asp:DropDownList Style=" margin-bottom:-5px;" ID="ddlCategories" runat="server" AutoPostBack="True" DataSourceID="CategoriesSqlDataSource"
            DataTextField="Category_name" DataValueField="Category_id" OnSelectedIndexChanged="ddlCategories_SelectedIndexChanged">
        </asp:DropDownList>
        <asp:SqlDataSource ID="CategoriesSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:FlowerStoreConnectionString %>"
            SelectCommand="SELECT Category_id, Category_name FROM Category UNION ALL SELECT NULL AS Category_id, 'Все' AS Category_name">
        </asp:SqlDataSource>
        <asp:ListView ID="ListView1" runat="server" DataKeyNames="Product_id" DataSourceID="ProductsSqlDataSource"
            InsertItemPosition="LastItem">
            <EmptyDataTemplate>
                <table runat="server" style="">
                    <tr>
                        <td>
                            В категории нет товаров
                        </td>
                    </tr>
                </table>
            </EmptyDataTemplate>
            <InsertItemTemplate>
                <tr style="">
                    <td>
                        <asp:Button ID="btnInsert" runat="server" Text="Добавить товар" OnClick="Insert_Click" />
                    </td>
                    <td>
                    </td>
                    <td>
                    </td>
                    <td>
                    </td>
                    <td>
                    </td>
                    <td>
                    </td>
                    <td>
                    </td>
                    <td>
                    </td>
                    <td>
                    </td>
                </tr>
            </InsertItemTemplate>
            <AlternatingItemTemplate>
            <tr style="background-color: #FFF8DC; color: #000000;">
                    <td  class="AdminTabCell">
                        <asp:Label ID="Product_nameLabel" runat="server" Text='<%# Eval("Product_name") %>' />
                    </td>
                    <td  class="AdminTabCell">
                        <asp:Label ID="Product_articleLabel" runat="server" Text='<%# Eval("Product_article") %>' />
                    </td>
                    <td  class="AdminTabCell">
                        <asp:Label ID="Product_descriptionLabel" runat="server" Text='<%# Eval("Product_description") %>' />
                    </td>
                    <td  class="AdminTabCell">
                    <a alt="Открыть изображение в новой вкладке" href="<%# Eval("Product_imgUrl") %>" > просмотреть... </a>
                        <%--<asp:Image ID="Image1" runat="server" AlternateText='<%# Eval("Product_imgUrl") %>' ImageUrl='<%# Eval("Product_imgUrl") %>' />--%>
                    </td>
                    <td  class="AdminTabCell">
                        <asp:Image ID="Image2" runat="server" AlternateText='<%# Eval("Product_imgUrl") %>' ImageUrl='<%# Eval("Product_thimbnailUrl") %>' />
                    </td>
                    <td  class="AdminTabCell">
                        <asp:Label ID="Product_priceLabel" runat="server" Text='<%# Eval("Product_price") %>' />
                    </td>
                    <td  class="AdminTabCell">
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("categories") %>' />
                    </td>
                    <td  class="AdminTabCell">
                        <asp:Label ID="Product_buyStatisticsLabel" runat="server" Text='<%# Eval("Product_buyStatistics") %>' />
                    </td>
                    <td  class="AdminTabCell">
                        <asp:Button ID="btnEdit" runat="server" Text="Редактировать" OnClick="Edit_Click"
                            CommandArgument='<%# Eval("Product_id") %>' />
                        <asp:Button ID="btnDeleteFromCategory" runat="server" Text="Удалить из категории"
                            OnClick="DeleteFromCat_Click" CommandArgument='<%# Eval("Product_id") %>' />
                        <asp:Button ID="btnDeleteFromCatalog" runat="server" Text="Удалить из каталога" OnClick="Delete_Click"
                            CommandArgument='<%# Eval("Product_id") %>' />
                    </td>
                </tr>
            </AlternatingItemTemplate>
            <ItemTemplate>
                <tr style="background-color: #DCDCDC; color: #000000;">
                    <td  class="AdminTabCell">
                        <asp:Label ID="Product_nameLabel" runat="server" Text='<%# Eval("Product_name") %>' />
                    </td>
                    <td  class="AdminTabCell">
                        <asp:Label ID="Product_articleLabel" runat="server" Text='<%# Eval("Product_article") %>' />
                    </td>
                    <td  class="AdminTabCell">
                        <asp:Label ID="Product_descriptionLabel" runat="server" Text='<%# Eval("Product_description") %>' />
                    </td>
                    <td  class="AdminTabCell">
                        <a alt="Открыть изображение в новой вкладке" href="<%# Eval("Product_imgUrl") %>"> просмотреть... </a>
                        <%--<asp:Image runat="server" AlternateText='<%# Eval("Product_imgUrl") %>' ImageUrl='<%# Eval("Product_imgUrl") %>' />--%>
                    </td>
                    <td  class="AdminTabCell">
                        <asp:Image runat="server" AlternateText='<%# Eval("Product_imgUrl") %>' ImageUrl='<%# Eval("Product_thimbnailUrl") %>' />
                    </td>
                    <td  class="AdminTabCell">
                        <asp:Label ID="Product_priceLabel" runat="server" Text='<%# Eval("Product_price") %>' />
                    </td>
                    <td  class="AdminTabCell">
                        <asp:Label runat="server" Text='<%# Eval("categories") %>' />
                    </td>
                    <td  class="AdminTabCell">
                        <asp:Label ID="Product_buyStatisticsLabel" runat="server" Text='<%# Eval("Product_buyStatistics") %>' />
                    </td>
                    <td  class="AdminTabCell">
                        <asp:Button ID="btnEdit" runat="server" Text="Редактировать" OnClick="Edit_Click"
                            CommandArgument='<%# Eval("Product_id") %>' />
                        <asp:Button ID="btnDeleteFromCategory" runat="server" Text="Удалить из категории"
                            OnClick="DeleteFromCat_Click" CommandArgument='<%# Eval("Product_id") %>' />
                        <asp:Button ID="btnDeleteFromCatalog" runat="server" Text="Удалить из каталога" OnClick="Delete_Click"
                            CommandArgument='<%# Eval("Product_id") %>' />
                    </td>
                </tr>
            </ItemTemplate>
            <LayoutTemplate>
                <table runat="server">
                    <tr runat="server">
                        <td runat="server">
                            <table id="itemPlaceholderContainer" runat="server" class="AdminTable">
                                <tr runat="server">
                                    <th class="AdminTabTopLineCell" runat="server">
                                        Название товара
                                    </th>
                                    <th class="AdminTabTopLineCell" id="Th2" runat="server">
                                        Артикул
                                    </th>
                                    <th class="AdminTabTopLineCell" id="Th3" runat="server">
                                        Описание
                                    </th>
                                    <th class="AdminTabTopLineCell" runat="server">
                                        Изображение
                                    </th>
                                    <th class="AdminTabTopLineCell" id="Th4" runat="server">
                                        Уменьшенное изображение
                                    </th>
                                    <th class="AdminTabTopLineCell" id="Th1" runat="server">
                                        Цена, руб.
                                    </th>
                                    <th class="AdminTabTopLineCell" runat="server">
                                        Категории
                                    </th>
                                    <th class="AdminTabTopLineCell" runat="server">
                                        Куплено, шт. </th>
                                    <th class="AdminTabTopLineCell"/>
                                    <th runat="server" />
                                </tr>
                                <tr id="itemPlaceholder" runat="server">
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr runat="server">
                        <td runat="server" style="text-align: center;">
                            <asp:DataPager ID="DataPager1" runat="server">
                                <Fields>
                                    <asp:NumericPagerField ButtonType="Link" />
                                </Fields>
                            </asp:DataPager>
                        </td>
                    </tr>
                </table>
            </LayoutTemplate>
        </asp:ListView>
        <asp:SqlDataSource ID="ProductsSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:FlowerStoreConnectionString %>"
            SelectCommand="GetCategoryProducts" SelectCommandType="StoredProcedure">
            <%-- <SelectParameters>
                <asp:ControlParameter ControlID="ddlCategories" Name="CategoryId" PropertyName="SelectedValue" 
                    Type="Int64" DefaultValue=""  ConvertEmptyStringToNull="true"/>
            </SelectParameters>--%>
        </asp:SqlDataSource>
    </div>
</asp:Content>
